<template>
  <div class="pagination">
    <el-pagination
      :current-page="current"
      :page-size="pageSize"
      :page-sizes="pageSizes"
      :background="background"
      :layout="layout"
      :total="pageTotal"
      @size-change="sizeChange"
      @current-change="currents"
      :size="size"
    />
  </div>
</template>

<script setup lang="ts" name="Pagination">
defineProps({
  size:{
    type: String,
    default:'default'
  },
  pageTotal: {
    type: Number,
    default: 0, //总页数
  },
  background: {
    type: Boolean,
    default: true,
  },
  pagerCount: {
    type: Number,
    default: 5, //如果页数很多大概展示的页码
  },
  layout: {
    type: String,
    default: "total,sizes, prev, pager, next, jumper, ->, slot", //分页组件会展示的功能项
  },
  pageSizes: {
    type: Array,
    default: () => {
      return [20, 30, 50, 60]; //指定分页展示条数
    },
  },
  pageSize: {
    type: Number,
    default: 20, //每页展示的条数
  },
  current: {
    type: Number,
  },
});

const emit = defineEmits(["sizeChange", "currentChange"]);

//选择每页显示数量
const sizeChange = (val: number) => {
  emit("sizeChange", val);
};

//选择某一页
const currents = (val: number) => {
  emit("currentChange", val);
};
</script>

<style scoped lang="scss">
.pagination {
  height: 40px;
  display: flex;
  justify-content: right;
  align-items: center;
}
</style>
